package com.vsen.lpr.controller;

import com.vsen.lpr.common.base.BaseController;
import com.vsen.lpr.pojo.dto.measure.MeansureListDto;
import com.vsen.lpr.pojo.dto.measure.TodayIsInputDto;
import com.vsen.lpr.pojo.vo.TodayMeasureVo;
import com.vsen.lpr.pojo.vo.UserMeasureVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

import com.vsen.lpr.common.model.Response;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.vsen.lpr.pojo.dto.measure.InsertUserMeasureRecordDto;
import com.vsen.lpr.pojo.vo.UserMeasureHistoryVo;
import com.vsen.lpr.service.MeasureService;

@Controller
@RequestMapping("/measure")
@Slf4j
public class MeasureController extends BaseController {

    @Autowired
    private MeasureService measureService;

    /**
     * 今天输入情况
     *
     * @param dto
     * @return
     */
    @PostMapping("/todayIsInput")
    @ResponseBody
    Response<TodayMeasureVo> todayIsInput(@RequestBody TodayIsInputDto dto)  {
        return measureService.todayIsInput(dto);
    }


    /**
     * 插入测量数据
     *
     * @param dto
     * @return
     */
    @PostMapping("/insert")
    @ResponseBody
    Response insertMeasureRecord(@RequestBody InsertUserMeasureRecordDto dto) throws Exception {
        return measureService.insertMeasureRecord(dto);
    }




    /**
     * 统计历史数据
     *
     * @param
     * @return
     */
    @PostMapping("/history")
    @ResponseBody
    Response<List<UserMeasureHistoryVo>> measureHistory(@RequestBody @Validated MeansureListDto dto, BindingResult bindingResult) throws ParseException {
        checkParameters(bindingResult);
        return measureService.userMeasureHistory(dto);
    }
}
